<template>
  <div>
    <van-cell-group border>
      <van-field v-model="password" label="密码" placeholder="请输入密码.." autofocus/>
    </van-cell-group>
    <div class="loginBtn">
      <van-button type="danger" :disabled="flag" round block @click="register">完成</van-button>
    </div>
  </div>
</template>

<script>
import {doRegister} from "../../api/user"
export default {
  data () {
    return {
      tel:'',
      password:"",
    }
  },
  computed:{
    flag(){
      if(/^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])\S*$/.test(
          this.password
        )){
        return false;
      }else {
        return true;
      }
    }
  },
  methods: {
    register() {
      doRegister({
        tel: localStorage.getItem("tel"),
        password: this.password,
      }).then(() => {
        //    console.log(res);
        this.$router.go(-3);
      });
    },
  },
}
</script>

<style>
.loginBtn{
  width: 80%;
  margin: 20px auto;
}
</style>